package com.lzs.Service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lzs.DAO.PolicyDAO;
import com.lzs.PO.Area;
import com.lzs.PO.Page;
import com.lzs.PO.Policy;
import com.lzs.Service.PolicyService;

@Service
public class PolicyServiceImpl implements PolicyService {

	@Autowired
	PolicyDAO policyDAO;
	
	public Page<Policy> findPolicyPageList(String keyword, Integer pageSize, Integer pageNum) {
		
		List<Policy> arealist = this.policyDAO.findPolicyList(keyword);

		int totalRecord = arealist.size();

		Page<Policy> page = new Page<Policy>(pageNum, pageSize, totalRecord);

		int startIndex = page.getStartIndex();

		page.setList(policyDAO.findPolicyPagelist(keyword, startIndex, pageSize));
		
		return page;
	}

	
	public void addPolicy(Map<String, Object> map) {

              this.policyDAO.addPolicy(map);
		
	}


	@Override
	public Policy findPolicyByYear(String year) {

        Policy policy = this.policyDAO.findPolicyByYear(year);
        
		return policy;
	}


	@Override
	public void updatePolicy(Map<String, Object> map) {
		
		this.policyDAO.updatePolicy(map);
		
	}


	@Override
	public void deletePolicy(String year) {
		
		this.policyDAO.deletePolicy(year);
		
	}

}
